<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Cropper js</title>

    <link rel="stylesheet" href="../../assets/libs/bootstrap/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="../../assets/libs/cropperjs/cropper.css">
    <link rel="stylesheet" href="../../assets/libs/cropperjs/main.css">
</head>
<body>
<!-- Content -->
<div class="container">
    <div class="row">
        <div class="col-md-9">
            <!-- <h3>Demo:</h3> -->
            <div class="img-container">
                <img src="../../assets/images/picture.jpg" alt="Picture">
            </div>
        </div>
        <div class="col-md-3">
            <!-- <h3>Preview:</h3> -->
            <div class="docs-preview clearfix">
                <div class="img-preview preview-md"></div>
            </div>
        </div>
    </div>

    <button type="button" class="btn btn-secondary" id="btn">
          <span class="docs-tooltip">
            Get Data
          </span>
    </button>
</div>
<script src="../../assets/libs/jquery/dist/jquery.min.js"></script>
<script src="../../assets/libs/cropperjs/cropper.js"></script>
<script>
    $(function () {
        var container = document.querySelector('.img-container');
        var image = container.getElementsByTagName('img').item(0);
        var options = {
            aspectRatio: 1/ 1,
            preview: '.img-preview',
            viewMode: 3
        };
        var cropper = new Cropper(image, options);

        $('#btn').on('click', function () {
            alert(JSON.stringify(cropper.getData()));
            // var result = cropper.getCroppedCanvas({ maxWidth: 4096, maxHeight: 4096 });
            // alert(result.toDataURL());
        });
    });
</script>
</body>
</html>